package com.wyl.aop.aspect.service.impl;

import com.wyl.aop.aspect.annotion.Aspect4jAnnotion;
import com.wyl.aop.aspect.service.AspectAopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 * @author 吴宇亮 on 2023/4/11 10:34
 */
@Service
public class AspectAopServiceImpl implements AspectAopService {

    @Autowired
    @Lazy
    private AspectAopService aspectAopService;

    @Aspect4jAnnotion
    @Override
    public String getStr1(String str) {
        // 测试this调用和引用调用是否能触发aop
        this.getStr2("this调用接口方法");
        aspectAopService.getStr2("方法内引用调用接口方法");
        this.getStr3("this调用public的非接口方法");
        this.getStr3("this调用private的非接口方法");

        System.out.println(str);
        return str;
    }

    // 测试aspect4j能否触发私有方法
    @Aspect4jAnnotion
    @Override
    public String getStr2(String str) {
        System.out.println(str);
        return str;
    }

    @Aspect4jAnnotion
    public String getStr3(String str) {
        System.out.println(str);
        return str;
    }

    @Aspect4jAnnotion
    private String getStr4(String str) {
        System.out.println(str);
        return str;
    }
}
